package com.oocl.command;

import java.io.IOException;
import java.io.OutputStream;
import java.text.ParseException;

import com.oocl.dao.DeptmentDao;
import com.oocl.dao.PersonDao;
import com.oocl.dao.impl.DeptmentDaoImpl;
import com.oocl.dao.impl.PersonDaoImpl;

public class Add {
	private static String line;
	private static OutputStream out;

	public Add (String line, OutputStream out) {
		super();
		this.line = line;
		this.out = out;
	}
	
	public void addPerson () throws ParseException, IOException {
		PersonDao personDao = new PersonDaoImpl();
		KeyValue kv = new KeyValue(line);
		int m = personDao.addPerson(kv.setPersonObject());
		if (m == 1) {
			//out.write("Add person success!\n".getBytes());
			//out.write("over".getBytes());
		}
	}
	
	public void addDept () throws IOException {
		DeptmentDao deptmentDao = new DeptmentDaoImpl();
		KeyValue kv = new KeyValue(line);
		int m = deptmentDao.addDept(kv.setDeptObject());
		if (m == 1) {
			//out.write("Add department success!\n".getBytes());
			//out.write("over".getBytes());
		}
	}
}
